<?php
/**
*Database handling instance factory class . 
*
* @author Liu Xiao <seanliu707@gmail.com>
* @see Idb.class.php
* @since 1.0
*/
interface Idb {
	public function insert( $_table, &$_array );
	public function delete( $_table, $_where );
	public function getList( $_query, $_type = NULL );
	public function getOneRow( $_query, $_type = NULL );
	public function update( $_table, &$_array, $_where );
	public function getRowNum( $_query );
	public function count( $_table, $_field = 0, $_where = NULL );
}

class DbFactory {
	private static $_classes = NULL;
	
	public static function create( $_class, &$_host ) {
		if ( self::$_classes == NULL ) {
			self::$_classes = array();
		}
		
		$_class = ucfirst( $_class );
		if ( ! isset( self::$_classes[$_class] ) ) {
			require  __DIR__ . DIRECTORY_SEPARATOR . $_class . '.class.php';
			self::$_classes[$_class] = true;
		}
		
		return new $_class($_host);
	}
}
